import * as types from './../constants/ActionTypes';

/*
 * 充值项列表
 ================================================================*/
export function fetchRecharge() {
  return  (dispatch) => {
    let payload = {
        recharge_status: 0,
        message: '加载中'
    };
    dispatch({
      payload,
      type: [types.FETCH_RECHARGES, types.FETCH_RECHARGES_SUCCESS, types.FETCH_RECHARGES_FAILURE],
      meta: {
        fetch: [`recharge/priceid`, {
          method: 'get'
        }]
      }  
    });
  };
}

/*
 * 充值记录
 ================================================================*/
export function fetchRechargeRecord({start = 1, limit = 10} = {}) {
  let payload = {
      recharge_record_status: 0,
      message: '加载中',
      start : start
  };
  return  (dispatch) => {
    dispatch({
      payload,
      type: [types.FETCH_RECHARGE_RECORDS, types.FETCH_RECHARGE_RECORDS_SUCCESS, types.FETCH_RECHARGE_RECORDS_FAILURE ],
      meta: {
        fetch: [`member/recharge?page_no=${start}&page_size=${limit}`, {
          method: 'get'
        }]
      } 
    });
  };
}

/*
 * 充值记录 - 复位
 ================================================================*/
export function resetRechargeRecord(){
  return (dispatch) => {
        let payload = {
            recharge_record_status: 0,
            message: '加载中',
            start : 1,
            results : []
        };
        
        dispatch({
            payload,
            type : types.RESET_RECHARGE_RECORDS
        });
    };
}